package com.yilin.tms.capital.commons.strategy.tools;

import com.yilin.commons.exception.BusinessException;
import com.yilin.tms.capital.commons.strategy.operation.BankOperation;
import com.yilin.tms.capital.service.IPsbService;
import com.yilin.tms.core.entity.capital.TradeRecord;
import com.yilin.tms.core.entity.user.account.Account;

import java.util.Collections;
import java.util.List;

// 邮政银行支付
public class PsbBankOperation implements BankOperation {//添加需要在BankOperationFactory.class添加判断
    private final IPsbService psbService;

    public PsbBankOperation(IPsbService psbService) {
        this.psbService = psbService;
    }

    /**
     * 支付
     * */
    @Override
    public void execute(List<TradeRecord> tradeRecordList, Account account) {
        psbService.paymentTransfe(tradeRecordList,account);
    }
    /**
     * 退款
     * */
    @Override
    public TradeRecord executeRefund(TradeRecord tradeRecord, Account account) {
        psbService.paymentTransfe(Collections.singletonList(tradeRecord), account);
        return tradeRecord;
    }
    /**
     * 查询
     * */
    @Override
    public TradeRecord executeQuery(TradeRecord tradeRecordList, Account account) {
        throw  new BusinessException("邮政银行该接口未配置策略模式");
    }
}